home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Complete Linux
/
Complete Linux.iso
/
xwindows
/
demos
/
xfract_1.z
/
xfract_1
/
xfractint-1.06
/
video.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-28
|
16KB
|
729 lines
#include <curses.h>
#include <string.h>
#include "fractint.h"
#include "prototyp.h"
/*
* This file contains Unix versions of the routines in video.asm
* Copyright 1992 Ken Shirriff
*/
extern int colors,rotate_lo,rotate_hi;
extern int boxx[],boxy[],boxcount;
extern unsigned char *xgetfont();
WINDOW *curwin;
extern int boxcount;
extern int dotmode;
extern int sxdots,sydots,sxoffs,syoffs;
int daclearn = 0;
int dacnorm = 0;
int daccount = 0;
int ShadowColors;
int goodmode = 0; /* if non-zero, OK to read/write pixels */
void (*dotwrite)(int, int, int);
/* write-a-dot routine */
int (*dotread)(int, int); /* read-a-dot routine */
void (*linewrite)(); /* write-a-line routine */
void (*lineread)(); /* read-a-line routine */
int andcolor = 0; /* "and" value used for color selection */
int diskflag = 0; /* disk video active flag */
int videoflag = 0; /* special "your-own-video" flag */
void (*swapsetup)(void) =NULL; /* setfortext/graphics setup routine */
int color_dark = 0; /* darkest color in palette */
int color_bright =0; /* brightest color in palette */
int color_medium =0; /* nearest to medbright grey in palette
Zoom-Box values (2K x 2K screens max) */
int boxcolor = 0; /* Zoom-Box color */
int reallyega = 0; /* 1 if its an EGA posing as a VGA */
int gotrealdac = 0; /* 1 if loaddac has a dacbox */
int rowcount = 0; /* row-counter for decoder and out_line */
int video_type = 0; /* actual video adapter type:
0 = type not yet determined
1 = Hercules
2 = CGA (assumed if nothing else)
3 = EGA
4 = MCGA
5 = VGA
6 = VESA (not yet checked)
11 = 8514/A (not yet checked)
12 = TIGA (not yet checked)
13 = TARGA (not yet checked)
100 = x monochrome
101 = x 256 colors
*/
int svga_type = 0; /* (forced) SVGA type
1 = ahead "A" type
2 = ATI
3 = C&T
4 = Everex
5 = Genoa
6 = Ncr
7 = Oak-Tech
8 = Paradise
9 = Trident
10 = Tseng 3000
11 = Tseng 4000
12 = Video-7
13 = ahead "B" type
14 = "null" type (for testing only) */
int mode7text = 0; /* nonzero for egamono and hgc */
int textaddr = 0xb800; /* b800 for mode 3, b000 for mode 7 */
int textsafe = 0; /* 0 = default, runup chgs to 1
1 = yes
2 = no, use 640x200
3 = bios, yes plus use int 10h-1Ch
4 = save, save entire image */
int text_type = 1; /* current mode's type of text:
0 = real text, mode 3 (or 7)
1 = 640x200x2, mode 6
2 = some other mode, graphics */
int textrow = 0; /* for putstring(-1,...) */
int textcol = 0; /* for putstring(..,-1,...) */
int textrbase = 0; /* textrow is relative to this */
int textcbase = 0; /* textcol is relative to this */
extern unsigned char dacbox[];
int vesa_detect = 1; /* set to 0 to disable VESA-detection */
/*
; |--Adapter/Mode-Name------|-------Comments-----------|
; |------INT 10H------|Dot-|--Resolution---|
; |key|--AX---BX---CX---DX|Mode|--X-|--Y-|Color|
*/
struct videoinfo videotable[MAXVIDEOTABLE] = {
{"xfractint mode "," ",
999, 0, 0, 0, 0, 19, 640, 480, 256},
{"unused mode "," ",
0, 0, 0, 0, 0, 0, 0, 0, 0},
};
void setforgraphics();
void
nullwrite(a,b,c)
int a,b,c;
{}
int
nullread(a,b)
int a,b;
{
return 0;
}
void setnullvideo()
{
dotwrite = nullwrite;
dotread = nullread;
}
void normalineread();
void normaline();
/*
; ********************** Function setvideotext() ************************
; Sets video to text mode, using setvideomode to do the work.
*/
void
setvideotext() {
dotmode = 0;
setvideomode(3,0,0,0);
}
/*
; **************** Function setvideomode(ax, bx, cx, dx) ****************
; This function sets the (alphanumeric or graphic) video mode
; of the monitor. Called with the proper values of AX thru DX.
; No returned values, as there is no particular standard to
; adhere to in this case.
; (SPECIAL "TWEAKED" VGA VALUES: if AX==BX==CX==0, assume we have a
; genuine VGA or register compatable adapter and program the registers
; directly using the coded value in DX)
; Unix: We ignore ax,bx,cx,dx. dotmode is the "mode" field in the video
; table. We use mode 19 for the X window.
*/
void
setvideomode(ax,bx,cx,dx)
int ax,bx,cx,dx;
{
if (diskflag) {
enddisk();
}
if (videoflag) {
endvideo();
videoflag = 0;
}
goodmode = 1;
switch (dotmode) {
case 0: /* text */
clear();
/*
touchwin(curwin);
*/
wrefresh(curwin);
break;
case 11:
startdisk();
dotwrite = writedisk;
dotread = readdisk;
lineread = normalineread;
linewrite = normaline;
break;
case 19: /* X window */
wclear(curwin); /* ???? */
putstring(0, 0, 0,
"Press operation key, or <Esc> to return to Main Menu");
wrefresh(curwin);
dotwrite = writevideo;
dotread = readvideo;
lineread = readvideoline;
linewrite = writevideoline;
videoflag = 1;
startvideo();
setforgraphics();
break;
default:
printf("Bad mode %d\n", dotmode);
exit(-1);
}
if (dotmode !=0) {
loaddac();
andcolor = colors-1;
boxcount =0;
}
}
loaddac()
{
readvideopalette();
}
/*
; **************** Function getcolor(xdot, ydot) *******************
; Return the color on the screen at the (xdot,ydot) point
*/
int
getcolor(xdot,ydot)
int xdot,ydot;
{
int x1,y1;
x1 = xdot+sxoffs;
y1 = ydot+syoffs;
if (x1<0 || y1<0 || x1>=sxdots || y1>=sydots) return 0;
return dotread(x1,y1);
}
/*
; ************** Function putcolor(xdot, ydot, color) *******************
; write the color on the screen at the (xdot,ydot) point
*/
void
putcolor(xdot,ydot,color)
int xdot,ydot,color;
{
dotwrite(xdot+sxoffs,ydot+syoffs,color&andcolor);
}
/*
; **************** Function movecursor(row, col) **********************
; Move the cursor (called before printfs)
*/
void
movecursor(row,col)
int row, col;
{
if (row==-1) {
row = textrow;
} else {
textrow = row;
}
if (col==-1) {
col = textcol;
} else {
textcol = col;
}
wmove(curwin,row,col);
}
/*
; **************** Function keycursor(row, col) **********************
; Subroutine to wait cx ticks, or till keystroke pending
*/
keycursor(row,col)
{
int ch;
movecursor(row,col);
wrefresh(curwin);
waitkeypressed(0);
return getakey();
}
/*
; PUTSTR.asm puts a string directly to video display memory. Called from C by:
; putstring(row, col, attr, string) where
; row, col = row and column to start printing.
; attr = color attribute.
; string = far pointer to the null terminated string to print.
; Written for the A86 assembler (which has much less 'red tape' than MASM)
; by Bob Montgomery, Orlando, Fla. 7-11-88
; Adapted for MASM 5.1 by Tim Wegner 12-11-89
; Furthur mucked up to handle graphics
; video modes by Bert Tyler 1-07-90
; Reworked for: row,col update/inherit;
; 620x200x2 inverse video; far ptr to string;
; fix to avoid scrolling when last posn chgd;
; divider removed; newline ctl chars; PB 9-25-90
*/
void
putstring(row, col, attr, msg)
int row,col, attr;
CHAR far *msg;
{
int so=0;
if (row!=-1) textrow = row;
if (col!=-1) textcol = col;
if (attr & INVERSE || attr & BRIGHT) {
wstandout(curwin);
so = 1;
}
wmove(curwin,textrow+textrbase, textcol+textcbase);
while (1) {
if (*msg=='\0') break;
if (*msg=='\n') {
textcol = 0;
textrow++;
wmove(curwin,textrow+textrbase, textcol+textcbase);
} else {
char *ptr;
ptr = strchr(msg,'\n');
if (ptr==NULL) {
waddstr(curwin,msg);
break;
} else {
waddch(curwin,*msg);
}
}
msg++;
}
if (so) {
wstandend(curwin);
}
wrefresh(curwin);
fflush(stdout);
getyx(curwin,textrow,textcol);
textrow -= textrbase;
textcol -= textcbase;
}
/*
; setattr(row, col, at